package com.ypd.shop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ypd.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ypd.common.annotation.Log;
import com.ypd.common.core.controller.BaseController;
import com.ypd.common.core.domain.AjaxResult;
import com.ypd.common.enums.BusinessType;
import com.ypd.shop.domain.HouseDescription;
import com.ypd.shop.service.IHouseDescriptionService;
import com.ypd.common.utils.poi.ExcelUtil;
import com.ypd.common.core.page.TableDataInfo;

/**
 * 简化版拍卖房屋信息Controller
 * 
 * @author lin
 * @date 2025-02-28
 */

@RestController
@RequestMapping("/shop/description")
@Api(tags = "简化版拍卖房屋信息Controller")
public class HouseDescriptionController extends BaseController
{
    @Autowired
    private IHouseDescriptionService houseDescriptionService;

    /**
     * 查询简化版拍卖房屋信息列表
     */
    @ApiOperation("查询简化版拍卖房屋信息列表")
    @PreAuthorize("@ss.hasPermi('shop:description:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseDescription houseDescription)
    {
        startPage();
        List<HouseDescription> list = houseDescriptionService.selectHouseDescriptionList(houseDescription);
        return getDataTable(list);
    }

    /**
     * 导出简化版拍卖房屋信息列表
     */
    @ApiOperation("导出简化版拍卖房屋信息列表")
    @PreAuthorize("@ss.hasPermi('shop:description:export')")
    @Log(title = "简化版拍卖房屋信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseDescription houseDescription)
    {
        List<HouseDescription> list = houseDescriptionService.selectHouseDescriptionList(houseDescription);
        ExcelUtil<HouseDescription> util = new ExcelUtil<HouseDescription>(HouseDescription.class);
        util.exportExcel(response, list, "简化版拍卖房屋信息数据");
    }

    /**
     * 获取简化版拍卖房屋信息详细信息
     */
    @ApiOperation("获取简化版拍卖房屋信息详细信息")
    @PreAuthorize("@ss.hasPermi('shop:description:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") String itemId)
    {
        return success(houseDescriptionService.selectHouseDescriptionByItemId(itemId));
    }

    /**
     * 新增简化版拍卖房屋信息
     */
    @ApiOperation("新增简化版拍卖房屋信息")
    @PreAuthorize("@ss.hasPermi('shop:description:add')")
    @Log(title = "简化版拍卖房屋信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseDescription houseDescription)
    {
        return toAjax(houseDescriptionService.insertHouseDescription(houseDescription));
    }

    /**
     * 修改简化版拍卖房屋信息
     */
    @ApiOperation("修改简化版拍卖房屋信息")
    @PreAuthorize("@ss.hasPermi('shop:description:edit')")
    @Log(title = "简化版拍卖房屋信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseDescription houseDescription)
    {
        return toAjax(houseDescriptionService.updateHouseDescription(houseDescription));
    }

    /**
     * 删除简化版拍卖房屋信息
     */
    @ApiOperation("删除简化版拍卖房屋信息")
    @PreAuthorize("@ss.hasPermi('shop:description:remove')")
    @Log(title = "简化版拍卖房屋信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable String[] itemIds)
    {
        return toAjax(houseDescriptionService.deleteHouseDescriptionByItemIds(itemIds));
    }
}
